package com.test.baseGroovy

/**
 * XmlTest--GroovyTest
 *
 * @author: Jovi
 *
 * @createTime: 2018-06-13 11:43
 *
 * */
/*=====================简单的XML解析=========================*/
def url = XmlTest.getClassLoader().getResource("test2.xml").getPath()
println url
def langs = new XmlParser().parse(url) //获取 xml 文件的 langs 节点
println langs.attribute("type")

langs.language.each {
    println it.text()
}


/*=====================复杂的XML解析=========================*/
def metadata = new XmlParser().parse(XmlTest.getClassLoader().getResource("test4.xml").getPath())

def groupId = metadata.groupId.text()
def artifactiId = metadata.artifactId.text()
def version = metadata.version.text()

println groupId+":"+artifactiId+":"+version


def versioning = metadata.versioning
println versioning.latest.text()

def versions = versioning.versions
versions.version.each {
    println "version" + it.text()
}